package com.yanqu.road.server.cmd.activity.yqhotel;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.YqHotelProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.yqhotel.YqHotelModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_YQ_HOTEL_LEAVE_SCENE, desc = "阳泉酒家离开界面")
public class YqHotelLeaveSceneCmd extends AbstractCommand {

    int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        YqHotelProto.YqHotelLeaveSceneReqMsg reqMsg = YqHotelProto.YqHotelLeaveSceneReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        player.getModule(YqHotelModule.class).leaveScene(activityId);
    }

    @Override
    public void sendData(GamePlayer player) {
        YqHotelProto.YqHotelLeaveSceneRespMsg.Builder respMsg = YqHotelProto.YqHotelLeaveSceneRespMsg.newBuilder();
        respMsg.setRet(0);
        player.sendPacket(ClientProtocol.U_YQ_HOTEL_LEAVE_SCENE, respMsg);
    }
}
